package com.ruite.livepad;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

public class SplashActivity extends AppCompatActivity {
    private ImageView iv_logo;
    private ImageView iv_left_fly;
    private ImageView iv_right_fly;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        iv_logo = findViewById(R.id.iv_logo);
        iv_left_fly = findViewById(R.id.iv_left_fly);
        iv_right_fly = findViewById(R.id.iv_right_fly);

        final Animation animationLogo = AnimationUtils.loadAnimation(this, R.anim.translate_logo);
        animationLogo.setFillAfter(true);


        final Animation animationLeft = AnimationUtils.loadAnimation(this, R.anim.translate_left_fly);
        animationLeft.setFillAfter(true);


        final Animation animationRight = AnimationUtils.loadAnimation(this, R.anim.translate_right_fly);
        animationRight.setFillAfter(true);

        animationRight.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                SplashActivity.this.startActivity(intent);
                SplashActivity.this.finish();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                iv_logo.startAnimation(animationLogo);
                iv_left_fly.startAnimation(animationLeft);
                iv_right_fly.startAnimation(animationRight);
            }
        }, 1000);
    }
}
